import Vue from 'vue'
import App from './App.vue'

// 引入样式
import '@/style/normalize.scss'
import '@/style/resetElementUI.scss'
import '@/style/common.scss'

// 引入路由
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import router from './router/index'

// 引入store
import store from './store'

import API from '@/api'


// 引入element ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// 重写replace和push方法，防止报错
let originPush = VueRouter.prototype.push
let originReplace = VueRouter.prototype.replace
VueRouter.prototype.push =function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject);
  } else {
    originPush.call(this, location, () => {}, () => {})
  }
}
VueRouter.prototype.replace = function (location, resolve, reject) {
  if (resolve && reject) {
      originReplace.call(this, location, resolve, reject);
  } else {
      originReplace.call(this, location, () => {}, () => {});
  }
}


// 注册全局组件
import Return from '@/components/Return/Return.vue'
Vue.component('Return', Return)

Vue.config.productionTip = false


new Vue({
  render: h => h(App),
  router,
  store,
  beforeCreate() {
    Vue.prototype.$bus = this,
    Vue.prototype.$API = API
  }
}).$mount('#app')
